package com.kuang.lesson01;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

//Panel可以看成一个空间
public class TestPanel {
	public static void main(String args[])
	{
		Frame frame = new Frame();
		Panel panel = new Panel();
		
		frame.setLayout(null);
		
		frame.setBounds(300, 300, 500, 500);
		frame.setBackground(Color.blue);
		
		panel.setBounds(50, 50, 400, 400);
		panel.setBackground(Color.black);
		
		frame.add(panel);
		
		frame.setVisible(true);
		
		//监听事件,监听窗口关闭事件 System.exit(0)
		//适配器模式:
		frame.addWindowListener(new WindowAdapter()
				{
					public void windowClosing(WindowEvent e)
					{
						System.exit(0);
					}
				});
	}
}
